package com.oig.sys.log.entity;

import lombok.Data;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.io.Serializable;


/**
 * @author wuxl
 */
@Data
@Document(indexName = "sys_access_log")
public class TbSysLog implements Serializable {

    @Id
    private String id;

    /**
     * 操作用户id
     */
    @Field(type = FieldType.Integer)
    private Integer userId;

    /**
     * 操作用户
     */
    @Field(type = FieldType.Text)
    private String userName;

    /**
     * 操作用户ip
     */
    @Field(type = FieldType.Text)
    private String loginIp;

    /**
     * 操作时间
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Field(type = FieldType.Date)
    private java.util.Date optTime;

    /**
     * 系统id
     */
    @Field(type = FieldType.Integer)
    private Integer systemId;

    /**
     * 操作类型
     */
    @Field(type = FieldType.Integer)
    private Integer resourceId;

    /**
     *
     */
    @Field(type = FieldType.Text)
    private String optType;

    /**
     * 请求url
     */
    @Field(type = FieldType.Text)
    private String apiUrl;

    /**
     * 操作记录id
     */
    @Field(type = FieldType.Text)
    private String optObjId;

    /**
     * 操作内容
     */
    @Field(type = FieldType.Text)
    private String content;

    /**
     * 参数json
     */
    @Field(type = FieldType.Text)
    private String oldval;

    /**
     * 返回值json
     */
    @Field(type = FieldType.Text)
    private String newval;

    /**
     * 备注
     */
    @Field(type = FieldType.Text)
    private String remark;

    @Field(type = FieldType.Long)
    private Long exeTime;
    /**
     * 0-成功 1-失败
     */
    @Field(type = FieldType.Text)
    private String result;

    /**
     * 异常信息
     */
    @Field(type = FieldType.Text)
    private String exception;

    /**
     * 日志也做租户隔离
     */
    @Field(type = FieldType.Integer)
    private Integer tenantId;

    /**
     * 数据所属机构
     */
    @Field(type = FieldType.Text)
    private String tenantName;

    /**
     * 跟踪号
     */
    @Field(type = FieldType.Text)
    private String traceId;
}
